const defig=require('../../config/defig')
const mysql      = require('mysql');
const connection=mysql.createConnection(defig.mysqlConfig)
 
connection.connect(function(err){
    if(err){
        console.log('error conecting:'+ err.stack);
        return;
    }
    console.log('db successfully connected');
})
const query=(sql)=>{
    return new Promise((resolve, reject) => {
         connection.query(sql, function (error, results) {
        if (error){
          reject(error);  
        } 
        resolve(results)
     });
  })
}

module.exports=query